<div class="fixed-bar">
	<form class="layui-form layui-form-pane fixed-bar-form" action="{:url()}" method="get" id="hisi-table-search">
	<div class="layui-form-item">	
		<div class="layui-inline">
			<label class="layui-form-label">操作人</label>
			<div class="layui-input-inline">
				<input type="text" name="user_name" lay-verify="" placeholder="输入操作人" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label">操作地址</label>
			<div class="layui-input-inline">
				<input type="text" name="url_address" lay-verify="" placeholder="输入操作地址" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<input type="hidden" name="stat_type">
			<button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">搜索</button>
		</div>
	</div>
	</form>
</div>

<table id="dataTable"></table>
<div id="detailTpl" style="display:none;" class="pt20 pl20">
	<form class="layui-form layui-form-pane">
		<div class="layui-form-item">	
			<label class="layui-form-label" style="width: 90px">请求URL</label>
			<div class="layui-input-block" style="margin-left:90px;">
				<input type="text" readonly value="{{ d.url }}" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<pre class="layui-code" lay-title="请求参数" lay-skin="notepad" lay-height="500px">
			{{ d.json }}
			</pre>
		</div>
	</form>
</div>
<script type="text/html" id="toolbar">
    <div class="layui-btn-group fl">
        <a data-href="{:url('del?table=admin_log')}" class="layui-btn layui-btn-primary layui-btn-sm j-page-btns confirm layui-icon layui-icon-delete">删除</a>
        <a href="{:url('clear')}" refresh="yes" class="layui-btn layui-btn-primary layui-btn-sm j-ajax confirm layui-icon layui-icon-delete">清空所有</a>
    </div>
</script>
<script type="text/html" id="buttonTpl">
    <a href="javascript:void(0)" class="layui-btn layui-btn-primary layui-btn-sm detail" data-url="{{ d.url }}" data-param='{{ d.param }}' title="查看请求参数">请求参数</a>
</script>
{include file="block/layui" /}
<script type="text/javascript">
    layui.use(['table','form','opTable', 'jquery', 'tool', 'laydate', 'laytpl'], function() {
        var $ = layui.jquery;
        var table = layui.table;
        var laydate = layui.laydate;
        var layer = layui.layer;
        var laytpl = layui.laytpl;
        table.render({
            elem: '#dataTable'
            ,url: '{:url()}' //数据接口
            ,page: true //开启分页
            ,limit: 20
            ,limits: [20,50,100,150,200]
            ,skin: 'row'
            ,even: true
            ,text: {
                none : '暂无相关数据'
            }
            ,toolbar: '#toolbar'
            ,defaultToolbar: ['filter']
            ,cols: [[ //表头
                {type:'checkbox'}
                ,{field: 'uid', title: '操作者', templet: function(d) {
                    return '<a href="{:url()}?uid='+ d.uid +'&page=1" class="hisi-table-a-filter">' + d.user.nick + '</a>';
                }}
                ,{field: 'title', title: '操作名称'}
                ,{field: 'url', title: '操作地址', templet: function(d) {
                    return '<a href="' + d.url + '">' + d.url + '</a>';
                }}
                ,{field: 'remark', title: '操作备注'}
                ,{field: 'count', title: '操作统计'}
                ,{field: 'ip', title: 'IP地址'}
                ,{field: 'mtime', title: '最近访问',templet : "<div>{{layui.util.toDateString(d.mtime*1000, 'yyyy-MM-dd HH:mm:ss')}}</div>"}
                ,{title: '操作', templet: '#buttonTpl', fixed: 'right', width:100}
            ]]
        });
        // 查看详情
        $(document).on('click','.detail',function(){
        	var url = $(this).attr('data-url');
        	var param = $(this).attr('data-param');
        	var d = {};
        	d.url = url;
        	var json = $.parseJSON(param);
        	d.json = JSON.stringify(json, null, 4);
        	//console.log(d);
        	$('#detailTpl pre').html('{{ d.json }}');
        	var layerParam = layer.open({
				type: 1
				,shade: 0
				,area:'500px'
				,anim: parseInt(Math.random()*(6+1),10)
				,offset: '100px'
				,skin:'layui-layer-molv'
				,title:'请求参数'
				,content: laytpl($('#detailTpl').html()).render(d)
				,success: function(layero, index){
					layui.code({about:false});
				}
			});
        });
    });
</script>